﻿using Moq;
using Ninject;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

using SMS.Domain.Entities;
using SMS.Domain.Abstract;
using WebMatrix.WebData;
using SMS.Domain.Concrete;





namespace SMS.WebUI.Infrastructure
{
    public class NinjectControllerFactory : DefaultControllerFactory
    {
        private IKernel ninjectKernel;
        public NinjectControllerFactory()
        {
            ninjectKernel = new StandardKernel();
            AddBindings();
        }
        protected override IController GetControllerInstance(RequestContext requestContext,
        Type controllerType)
        {
            return controllerType == null
            ? null
            : (IController)ninjectKernel.Get(controllerType);
        }
        private void AddBindings() {

            ninjectKernel.Bind<IRetoRepository>().To<EFRetoRepository>();
            
            
            
            //// Mock implementation of the IRetoRepository Interface
            //Mock<IRetoRepository> mock = new Mock<IRetoRepository>();
            //mock.Setup(m => m.Retos).Returns(new List<Reto> {
            //    new Reto { Descripcion="Cómo hacer un mock repository?", FechaIns=DateTime.Parse("12/12/2011 23:00:00") },
            //    new Reto { Descripcion="Cómo manejar el SimpleMembership?", FechaIns=DateTime.Parse("12/01/2012 13:00:30") },
            //    new Reto { Descripcion="Cómo hacer un mock repository con el simpleMemeberShip?", FechaIns=DateTime.Parse("25/06/2012 15:30:00") }
            //}.AsQueryable());
            //ninjectKernel.Bind<IRetoRepository>().ToConstant(mock.Object);
        
        }
    }
}